'/
' GUI Library
' Written by Anton Berlin, 2010.
' 
' =========================================================================
' 
' This program is free software; you can redistribute it and/or modify
' it under the terms of the GNU Lesser General Public License as published
' by the Free Software Foundation; either version 3 of the License.
' 
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
' GNU General Public License for more details.
' 
' You should have received a copy of the GNU Lesser General Public License
' along with this program; if not, write to the Free Software
' Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
'/

superstrict

import "GUI_Layer.bmx"

type GUI_Surface

	'// -------------------------------------------------------------------------------------------------------------
	'// Draw this surface.
	'// -------------------------------------------------------------------------------------------------------------
	method draw()
	
		for local layer:GUI_Layer = eachin m_layerList
		
			layer.draw();
		
		next
	
	end method
	
	'// -------------------------------------------------------------------------------------------------------------
	'// Return a pointer to a layer from the layer containers.
	'// -------------------------------------------------------------------------------------------------------------
	method getLayer:GUI_Layer(name:string)
	
		return GUI_Layer(m_layerMap.valueForKey(name));
	
	end method
	
	'// -------------------------------------------------------------------------------------------------------------
	'// Add a layer to the layer containers.
	'// -------------------------------------------------------------------------------------------------------------
	method addLayer(name:string, visible:byte = false)
	
		local layer:GUI_Layer = new GUI_Layer;
		
		layer.m_name = name;
		layer.m_visible = visible;
		
		m_layerList.addLast(layer);
		m_layerListReversed.addFirst(layer);
		m_layerMap.insert(name, layer);
		
		layer.m_layerListLink = m_layerList.lastLink();
	
	end method
	
	'// -------------------------------------------------------------------------------------------------------------
	'// The name of this surface.
	'// -------------------------------------------------------------------------------------------------------------
	field m_name:string;
	
	'// -------------------------------------------------------------------------------------------------------------
	'// Pointer to the currently active gadget.
	'// -------------------------------------------------------------------------------------------------------------
	field m_activeGadget:GUI_Gadget;
	
	'// -------------------------------------------------------------------------------------------------------------
	'// Containers for layers.
	'// -------------------------------------------------------------------------------------------------------------
	field m_layerList:TList = new TList;
	field m_layerListReversed:TList = new TList;
	field m_layerMap:TMap = new TMap;
	
	'// -------------------------------------------------------------------------------------------------------------
	'// Pointer to the links in the surface lists in the GUI namespace in which this surface is contained.
	'// -------------------------------------------------------------------------------------------------------------
	field m_surfaceListLink:TLink;
	field m_surfaceListReversedLink:TLink;

end type
